package log_error;

import java.util.logging.Level;
import java.util.logging.Logger;

import main.MODULE;

/**
 * @author Chris Bayruns This is what we will throw when something goes wrong
 * @version $Revision: 1.0 $
 */
public class OfficeException extends Exception {

    /**
     * Field loc.
     */
    private MODULE loc = null;

    /** 
     * Field message.
     */
    private String message = null;

    /**
     * Field level.
     */
    private Level level = null;

    /**
     * Custom exception object to throw.
     * 
     * 
     * @param loc
     *            This will be the location that the exception was thrown from.
     * @param message
     *            This will be the more specific message as to what went wrong.
     * @param level
     *            This is the level of severity of the exception.
     */
    public OfficeException(MODULE loc, Level level, String message) {
	this.loc = loc;
	this.message = message;
	this.level = level;

	writeError();
    }

    /**
     * Constructor for OfficeException.
     */
    public OfficeException() {
	level = Level.INFO;
	message = "";
	loc = MODULE.OFFICE;
    }

    /**
    
     */
    private void writeError() {
	// ConsoleHandler err = new ConsoleHandler();
	final Logger log = Log.getDefaultLog();
	// LogRecord rec = new LogRecord(level, loc + ": " + message);
	// err.publish(rec);
	log.log(level, message, loc);
    }

    /**
     * 
     * 
     * @return the loc
     */
    public MODULE getLoc() {
	return loc;
    }

    /**
     * 
     * 
     * @return the message
     */
    public String getMessage() {
	return message;
    }

    /**
     * 
     * 
     * @return the level
     */
    public Level getLevel() {
	return level;
    }
}
